<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class BA_ES1Controller extends BaseController {
    /*
     * Konstruktor
     */

    public function __construct($registry) {
        parent::__construct($registry);
    }

    /*
     * Index
     */

    public function index() {
        
    }

    public function DataRealisasiKegiatanBA() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));



        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "SUBSTR(OUTPUT,1,4) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }
            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(nmkegiatan) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }


        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_ba_kegiatan_filter($filter);

        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Kegiatan';
        $this->view->judulkolom = 'Kode | Nama Kegiatan';
        $this->view->action = 'DataRealisasiKegiatanBA';
        $this->view->kodes = 'Kode Kegiatan :';
        $this->view->detil = "kegiatan";
        $this->view->render('baes1/DataRealisasiKegiatan');
    }

    public function DataRealisasiPenerimaanBA($bln_awal = null, 
	$bln_akhir = null,  $nama = null, $eselon1 = null, $satker = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
            $this->view->ba = Session::get('kd_baes1');
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = "KDSATKER = '" . Session::get('kd_satker') . "'";
        }
        if (Session::get('role') == KANWIL) {
            $filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
        }
		
		if ($bln_awal != 0 AND $bln_akhir != 0) {

          $filter[$no++] = "(A.PERIODE BETWEEN  '" . $bln_awal . "' AND '". $bln_akhir ."' OR A.PERIODE = 'B')";
		  $this->view->bln_awal1 = $bln_awal;
		  $this->view->bln_akhir1 = $bln_akhir;
		}    
		
        if ($nama != null) {
            $this->view->nama = urldecode($nama);
        }
        if ($eselon1 != null) {
            if (Session::get('role') == MENKEU || Session::get('role') == DJA || Session::get('role') == PNR) {
                $filter[$no++] = "BA = '" . $eselon1 . "'";
                //$filter[$no++] = "A.TGLPOST <=  TRUNC(SYSDATE-1) ";
            } else {
                $filter[$no++] = "BAES1 = '" . $eselon1 . "'";
            }
            $this->view->eselon1 = $eselon1;
        }
        if ($satker != null) {
            $filter[$no++] = "KDSATKER = '" . $satker . "'";
            $this->view->satker = $satker;
        }
		
		

        if (isset($_POST['submit_file'])) {

           if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        
		
        $d_log->tambah_log("Sukses");
		
		 if (Session::get('role') == SATKER) {
			 
			$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_satker($filter);
			$this->view->action = 'DataRealisasiPenerimaanBA';
			$this->view->render('baes1/DataRealisasiPenerimaanMenkeu');
		 }
		 
		 elseif (Session::get('role') == KANWIL) { 
			$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_kl($filter);
			$this->view->action = 'DataRealisasiPenerimaanBA';
			$this->view->render('baes1/DataRealisasiPenerimaan');
			
		}
        else { 
			//$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_kl($filter);
			//$this->view->action = 'DataRealisasiPenerimaanBA';
			//$this->view->render('baes1/DataRealisasiPenerimaan');
			$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_satker($filter);
			$this->view->action = 'DataRealisasiPenerimaanBA';
			$this->view->render('baes1/DataRealisasiPenerimaanMenkeu');
		}
    }
	
	
	public function DataRealisasiBA() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
        if (isset($_POST['submit_file'])) {
            

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }						
           
        }      

		if ((''.Session::get('ta')) == date("Y")) {			 					
				$this->view->data = $d_spm1->get_realisasi_fa_global_ba_filter($filter);
					
			}
				else {			  					
					$this->view->data = $d_spm1->get_realisasi_fa_global_ba_filter_tl($filter);
					
		}
      
        $d_log->tambah_log("Sukses");
		$this->view->action = 'DataRealisasiBA_BAES1';
        $this->view->render('kppn/DataRealisasiBA');
    }
    public function DataRealisasiPenerimaanMenkeu() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_ba_pendapatan_menkeu($filter);
		$this->view->action = 'DataRealisasiPenerimaanMenkeu';

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiPenerimaanMenkeu');
    }

    public function DataRealisasiPenerimaanPerES1() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }


        if (isset($_POST['submit_file'])) {      

           if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $this->view->data = $d_spm1->get_ba_per_kl_pendapatan_filter($filter);
            $this->view->kode_kolom = 'K/L';
        } else {

            //$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_kl($filter);
            $this->view->data = $d_spm1->get_ba_per_es1_pendapatan_filter($filter);
            $this->view->kode_kolom = 'Es. 1';
        }
		$this->view->action = 'DataRealisasiPenerimaanPerES1';
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiPenerimaanES1');
    }
	
	public function DataRealisasiPenerimaanPerKLMenkeu() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

      
            $this->view->data = $d_spm1->get_per_kl_pendapatan_menkeu($filter);
            $this->view->kode_kolom = 'K/L';
      
        $d_log->tambah_log("Sukses");
		$this->view->action = 'DataRealisasiPenerimaanPerKLMenkeu';

        $this->view->render('baes1/DataRealisasiPenerimaanES1');
    }
	
	public function DataRealisasiTransferMenkeu() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
		if (isset($_POST['submit_file'])) {           

            if ($_POST['kdlokasi'] != '') {
                $filter[$no++] = "lokasi = '" . $_POST['kdlokasi'] . "'";
                $this->view->lokasi = $_POST['kdlokasi'];
            }
            if ($_POST['provinsi'] != '') {
                $filter[$no++] = "KDPROVINSI = '" . $_POST['provinsi'] . "'";
                
                $this->view->provinsi = $_POST['provinsi'];
            }

            if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {

                $filter[$no++] = "TO_CHAR(ACCOUNTING_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }          
            
        }

        $this->view->data = $d_spm1->get_realisasi_transfer_menkeu($filter);
		$this->view->data4 = $d_spm1->get_realisasi_lokasi_kab();
		$this->view->data2 = $d_spm1->get_realisasi_lokasi_provinsi();
			
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiTransferMenkeu');
    }
	
	public function DataRealisasiDanaPerimbangan($akun) {
        $d_spm1 = new DataRealisasiES1($this->registry);
		$d_spm2 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
		if (isset($_POST['submit_file'])) {           

            if ($_POST['kdlokasi'] != '') {
                $filter[$no++] = "lokasi = '" . $_POST['kdlokasi'] . "'";
                $this->view->lokasi = $_POST['kdlokasi'];
            }
            if ($_POST['provinsi'] != '') {
                $filter[$no++] = "KDPROVINSI = '" . $_POST['provinsi'] . "'";
                
                $this->view->provinsi = $_POST['provinsi'];
            }

            if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {

                $filter[$no++] = "TO_CHAR(ACCOUNTING_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }          
            
        }
        
	
		if($akun == "654" or $akun == "655") {
			$filter[$no++] = "SUBSTR(AKUN,1,3) IN ('".$akun."') ";
		}
		else {
			$filter[$no++] = "SUBSTR(AKUN,1,2) IN ('".$akun."') ";
		
		}
		$this->view->d_akun = $akun;
		
		if ($akun == '61') {
		$this->view->judul = "Transfer Dana Bagi Hasil";
		}
		if ($akun == '62') {
		$this->view->judul = "Transfer Dana Alokasi Umum";
		}
		if ($akun == '63') {
		$this->view->judul = "Transfer Dana Alokasi Khusus";
		}
		if ($akun == '64') {
		$this->view->judul = "Transfer Dana Otonomi Khusus";		
		}
		if ($akun == '66') {
		$this->view->judul = "Transfer Dana Keistimewaan DIY";
		}
		if ($akun == '654') {
		$this->view->judul = "Transfer Dana Lainnya";
		}
		if ($akun == '655') {
		$this->view->judul = "Transfer Dana Desa";
		}
		
		
		$this->view->data = $d_spm1->get_realisasi_transfer_perbulan($filter);
		$this->view->data4 = $d_spm2->get_realisasi_lokasi_kab();
		$this->view->data2 = $d_spm2->get_realisasi_lokasi_provinsi();
		
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiTransferBulan');
    }

	
	
    public function DataPengembalianPenerimaan() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(BAES1,1,3) = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = "KDSATKER = '" . Session::get('kd_satker') . "'";
        }


        if (isset($_POST['submit_file'])) {

            if ($_POST['satker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['satker'] . "'";
                $this->view->SATKER = $_POST['satker'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $this->view->data = $d_spm1->get_pengembalian_pendapatan($filter);
        } else {
            $this->view->data = $d_spm1->get_pengembalian_pendapatan($filter);
        }
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataPengembalianPenerimaan');
    }
	
	 public function DataSektorPenerimaan($jenis, $ba = null, $nama = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
				
		
		
		if (isset($_POST['submit_file'])) {

            if ($_POST['satker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['satker'] . "'";
                $this->view->SATKER = $_POST['satker'];
            }
        }
		
		if ($jenis == 'pajak') {
			$this->view->judul = 'PENERIMAAN SEKTOR PAJAK';
			$this->view->kolom = 'KODE | NAMA SATKER';
			$this->view->jenis = 'pajak';
			$this->view->data = $d_spm1->get_pendapatan_pajak($filter);
			$this->view->jenis = 'pajak';
		}
		
		if ($jenis == 'cukai') {
			$this->view->judul = 'PENERIMAAN SEKTOR BEA DAN CUKAI';
			$this->view->kolom = 'KODE | NAMA SATKER';
			$this->view->jenis = 'cukai';
			$this->view->data = $d_spm1->get_pendapatan_cukai($filter);
			$this->view->jenis = 'cukai';
		}
		
		if ($jenis == 'pnbp') {
			$this->view->judul = 'PENERIMAAN SEKTOR PNBP';
			$this->view->jenis = 'pnbp';
			if ($ba != NULL) {
				$filter[$no++] = "BA = '" . $ba . "'";
				$this->view->kolom = 'KODE | NAMA SATKER';
				$this->view->nama = $nama;
				$this->view->ba = $ba;
				$this->view->data = $d_spm1->get_pendapatan_pnbp($filter);
			}
			else {
				$this->view->kolom = 'KODE | NAMA KEMENTERIAN/LEMBAGA';
				$this->view->data = $d_spm1->get_pendapatan_pnbp_global($filter);
			}	
			$this->view->jenis = 'pnbp';
		}
		
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

       
        
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataSektorPenerimaan');
    }
	public function DataDetailSektorPenerimaan($bln = null, $akun = null, $satker = null, $nama = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		
		if ($bln != null) {

          $filter[$no++] = "A.PERIODE =  '" . $bln . "'";
		  $this->view->bln = $bln;
		  
		}    
		
        if ($nama != null) {
            $this->view->nama = urldecode($nama);
        }
		
        if ($akun != null) {
				if($akun == 'pajak') {
                $filter[$no++] = "substr(akun,1,2) = '41'";
				$filter[$no++] = "substr(akun,1,4) <> '4115'";
				$filter[$no++] = "substr(akun,1,3) <>  '412' ";
				//$filter[$no++] = "flag ='A' ";
				}
				
				if($akun == 'cukai') {
                $filter[$no++] = "(substr(akun,1,4) = '4115' or  substr(akun,1,3) = '412')";
				//$filter[$no++] = "flag ='A' ";
				}
				
				if($akun == 'pnbp') {
                $filter[$no++] = "substr(akun,1,2) = '42'";
				//$filter[$no++] = "flag ='A' ";
				}
				$this->view->akun = $akun;
         
        }
        if ($satker != null) {
            $filter[$no++] = "KDSATKER = '" . $satker . "'";
            $this->view->d_kd_satker = $satker;
            $this->view->nama = urldecode($nama);
            $this->view->satker = $satker;
        }
		
		

        if (isset($_POST['submit_file'])) {

           if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        
		$this->view->data = $d_spm1->get_ba_pendapatan_per_akun_kl($filter);
        $d_log->tambah_log("Sukses");
		$this->view->action = 'DataDetailSektorPenerimaan';

        $this->view->render('baes1/DataRealisasiPenerimaan');
    }

    public function DataDetailPengembalianPenerimaan($satker = null, $tgl = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }


        if ($satker != '') {
            if (Session::get('role') == SATKER) {
                $filter[$no++] = " KDSATKER =  '" . Session::get('kd_satker') . "'";
            } else {
                $filter[$no++] = " KDSATKER =  '" . $satker . "'";
                $this->view->d_kd_satker = $satker;
            }
        }

        if ($tgl != '') {
            $filter[$no++] = " TO_CHAR(TGLPOST,'MM') =  '" . $tgl . "'";
            $this->view->d_tgl = $tgl;
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['nodok'] != '') {
                $filter[$no++] = "nodok = '" . $_POST['nodok'] . "'";
                $this->view->nodok = $_POST['nodok'];
            }

            if ($_POST['akun'] != '') {
                $filter[$no++] = "akun = '" . $_POST['akun'] . "'";
                $this->view->akun = $_POST['akun'];
            }
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
		//$this->view->data = $d_spm1->get_detail_pengembalian_pendapatan($filter);
		
        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $this->view->data = $d_spm1->get_detail_pengembalian_pendapatan($filter);
        } else {
            $this->view->data = $d_spm1->get_detail_pengembalian_pendapatan_baes1($filter);
        }
		
		
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DetailPengembalianPendapatan');
    }

    public function DataDetailAkunPotongan($bln_awal = null, $bln_akhir = null, $akun = null, $eselon1 = null, $satker = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " KDSATKER =  '" . Session::get('kd_satker') . "'";
        }

        if (Session::get('role') == KANWIL) {
            $filter[$no++] = " SUBSTR(KANWIL_DJPB,2,2) =  '" . Session::get('id_user') . "'";
        }

        if ($akun != '') {
            $filter[$no++] = " AKUN =  '" . $akun . "'";
            $this->view->akun = $akun;
        }

        if ($eselon1 != '') {
            $filter[$no++] = " BAES1 = '" . $eselon1 . "'";
            $this->view->eselon1 = $eselon1;
        }

        if ($satker != '') {
            $filter[$no++] = " KDSATKER =  '" . $satker . "'";
            $this->view->satker = $satker;
        }
		
		if ($bln_awal != 0 AND $bln_akhir != 0) {

          $filter[$no++] = "TO_CHAR(TGLPOST,'MM') BETWEEN '" . $bln_awal . "' AND '" . $bln_akhir . "'";
		  $this->view->bln_awal = $bln_awal;
		  $this->view->bln_akhir = $bln_akhir;
		}      

        if (isset($_POST['submit_file'])) {
            if ($_POST['nodok'] != '') {
                $filter[$no++] = "nodok = '" . $_POST['nodok'] . "'";
                $this->view->nodok = $_POST['nodok'];
            }

            if ($_POST['akun'] != '') {
                $filter[$no++] = "akun = '" . $_POST['akun'] . "'";
                $this->view->akun = $_POST['akun'];
            }
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $this->view->data = $d_spm1->get_detail_pengembalian_pendapatan($filter);
        } elseif (Session::get('role') == KANWIL) {
            $this->view->data = $d_spm1->get_detail_akun_potongan_kanwil($filter);
        } else {
            $this->view->data = $d_spm1->get_detail_akun_potongan($filter);
        }
        $d_log->tambah_log("Sukses");
        $this->view->action = 'DataDetailAkunPotongan';

        $this->view->judul = "Potongan";

        $this->view->render('baes1/DetailAkunPendapatan');
    }

    public function DataDetailAkunPengembalian($bln_awal = null, $bln_akhir = null, $akun = null, $eselon1 = null, $satker = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " KDSATKER =  '" . Session::get('kd_satker') . "'";
        }

        if (Session::get('role') == KANWIL) {
            $filter[$no++] = " SUBSTR(KANWIL_DJPB,2,2) =  '" . Session::get('id_user') . "'";
        }

        if ($akun != '') {
            $filter[$no++] = " AKUN =  '" . $akun . "'";
            $this->view->akun = $akun;
        }

        if ($eselon1 != '') {
            $filter[$no++] = " BAES1 =  '" . $eselon1 . "'";
            $this->view->eselon1 = $eselon1;
        }

        if ($satker != '') {
            $filter[$no++] = " KDSATKER =  '" . $satker . "'";
            $this->view->satker = $satker;
        }
		
		if ($bln_awal != 0 AND $bln_akhir != 0) {

                $filter[$no++] = "TO_CHAR(TGLPOST,'MM') BETWEEN '" . $bln_awal . "' AND '" . $bln_akhir . "'";
				$this->view->bln_awal = $bln_awal;
				$this->view->bln_akhir = $bln_akhir;
		}  

        if (isset($_POST['submit_file'])) {
            if ($_POST['nodok'] != '') {
                $filter[$no++] = "nodok = '" . $_POST['nodok'] . "'";
                $this->view->nodok = $_POST['nodok'];
            }

            if ($_POST['akun'] != '') {
                $filter[$no++] = "akun = '" . $_POST['akun'] . "'";
                $this->view->akun = $_POST['akun'];
            }
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $this->view->data = $d_spm1->get_detail_pengembalian_pendapatan($filter);
        } elseif (Session::get('role') == KANWIL) {
            $this->view->data = $d_spm1->get_detail_akun_pengembalian_kanwil($filter);
        } else {
            $this->view->data = $d_spm1->get_detail_akun_pengembalian($filter);
        }
        $d_log->tambah_log("Sukses");

        $this->view->judul = "Pengembalian";
        $this->view->action = 'DataDetailAkunPengembalian';

        $this->view->render('baes1/DetailAkunPendapatan');
    }

    public function DataRealisasiPenerimaanPerSatkerES1() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == KANWIL) {
            $filter[$no++] = "KANWIL_DJPB= 'K" . Session::get('id_user') . "'";
        }

        if (isset($_POST['submit_file'])) {

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->kdsatker = $_POST['kdsatker'];
            }
            if ($_POST['nmsatker'] != '') {
                $filter[$no++] = " UPPER(NMSATKER) LIKE UPPER('%" . $_POST['nmsatker'] . "%')";
                $this->view->nmsatker = $_POST['nmsatker'];
            }
            if ($_POST['eselon1'] != '') {
                $filter[$no++] = "BAES1 = '" . $_POST['eselon1'] . "'";
                $this->view->eselon1 = $_POST['eselon1'];
            }
			if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') != KANWIL) {
            $d_spm = new DataNamaSatker($this->registry);
            $this->view->data1 = $d_spm->get_es1_dipa_filter();
        } 
           
        $this->view->data = $d_spm1->get_kl_per_es1satker_pendapatan_filter($filter);
        
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiPenerimaanSatkerES1');
    }

    public function DataRealisasiAkunBA($baes1 = null, $bln_awal = null, $bln_akhir = null) {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));




        if (isset($_POST['submit_file'])) {

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '" . $_POST['bln_akhir'] . "' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
                $this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->nama = 'Eselon 1';


        if (Session::get('role') == KL) {
            if (('' . Session::get('ta')) == date("Y")) {

                $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter($filter);
            } else {

                $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter_tl($filter);
            }
        }

        if (Session::get('role') == ES1) {
            if (('' . Session::get('ta')) == date("Y")) {

                $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter($filter);
            } else {

                $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter_tl($filter);
            }
        }
		
		if (Session::get('role') == ADMIN || Session::get('role') == DJA) {
            if (('' . Session::get('ta')) == date("Y")) {
				if ($baes1 != '') { 
					$filter[$no++] = "BA = '" . $baes1 . "'";	
					$this->view->ba = $baes1;
				}
				if ($bln_awal != '' and  $bln_akihr != '') {
					 $filter[$no++] = "(A.PERIODE BETWEEN  '" . $bln_awal . "' AND '" . $bln_akihr . "' OR A.PERIODE = 'B')";				
				}
				 $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter($filter);
			} else {
				$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . $baes1 . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_global_kl_filter_tl($filter);
				$this->view->ba = $baes1;
			
			}
        }

        $d_log->tambah_log("Sukses");
		

        $this->view->render('baes1/DataRealisasiBA');
    }

    public function DataRealisasiAkunES1() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));


        if (Session::get('role') == KL) {
            //$filter[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
						
		
        if (isset($_POST['submit_file'])) {

            if ($_POST['satker'] != '') {
                $filter[$no++] = "SATKER = '" . $_POST['satker'] . "'";
                $this->view->satker = $_POST['satker'];
            }

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '" . $_POST['bln_akhir'] . "' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
                $this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->nama = 'Satker';

        if (('' . Session::get('ta')) == date("Y")) {
            $this->view->data = $d_spm1->get_realisasi_fa_baes1_filter($filter);
        } else {
            $this->view->data = $d_spm1->get_realisasi_fa_baes1_filter_tl($filter);
        }

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiES1');
    }

    public function DataRealisasiKewenanganBAES1() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

       
       
		
        if (isset($_POST['submit_file'])) {

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }
		
		if (Session::get('role') == KANWIL) {
           
			if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "KANWIL = '" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
        }
		
		if (Session::get('role') == KL) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == ES1) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == MENKEU) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter($filter);
				}
				else {
			  
					
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}

        $d_log->tambah_log("Sukses");
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->render('baes1/DataRealisasiKewenaganBAES1');
    }
	
	public function DataDetailKewenanganBAES1($bln_awal = null, $bln_akhir = null, $kewenangan = null, $deskripsi) {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		
		if ($bln_awal != 0 AND $bln_akhir != 0) {

          $filter[$no++] = "A.PERIODE BETWEEN '" . $bln_awal . "' AND '" . $bln_akhir . "'";
		 
		  $this->view->bln_awal = $bln_awal;
		  $this->view->bln_akhir = $bln_akhir;
		}    
		
		if ($kewenangan != '') {
			$filter[$no++] = "A.KEWENANGAN = '" . $kewenangan . "'";
			if($kewenangan != 'Z') {
				$this->view->kewenangan = urldecode($deskripsi);
				$this->view->deskripsi = $deskripsi;
				$this->view->kd_kewenangan = $kewenangan;
			}
			else {
				$this->view->kewenangan = 'Suspense';
			}
		}
		
		
		if (Session::get('role') == KANWIL) {
           
			if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_detail_kewenangan_filter($filter);
				}
				else {
			  
					$filter[$no++] = "KANWIL = '" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
        }
		
		if (Session::get('role') == KL) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_detail_kewenangan_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == ES1) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_detail_kewenangan_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == MENKEU) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					
					$this->view->data = $d_spm1->get_realisasi_detail_kewenangan_filter($filter);
				}
				else {
			  
					
					$this->view->data = $d_spm1->get_realisasi_fa_kewenangan_baes1_filter_tl($filter);
				}
		}

        $d_log->tambah_log("Sukses");
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->render('baes1/DataDetailKewenaganBAES1');
    }

    public function DetailEncumbrances($code_id = null, $judul = null, $detil) {
        $d_spm1 = new encumbrances($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        $filter[$no++] = "TO_CHAR(NEED_BY_DATE,'YYYY') =" . Session::get('ta');

        $this->view->kd_detil = $detil;
        //detil encumbrance ba
        if (Session::get('role') == KL) {
            $filter[$no++] = " SUBSTR(B.SEGMENT4,1,3) =  '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(B.SEGMENT4,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "B.SEGMENT2 IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = " B.SEGMENT1 =  '" . Session::get('kd_satker') . "'";
        }

        if ($detil == 'eselon') {
            $filter[$no++] = " SUBSTR(B.SEGMENT4,1,5) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'satker') {
            if (Session::get('role') == ES1) {
                $filter[$no++] = " B.SEGMENT1 =  '" . $code_id . "'";
            } else {
                $filter[$no++] = " SUBSTR(B.SEGMENT4,1,5)||'-'||B.SEGMENT1 =  '" . $code_id . "'";
            }
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'kegiatan') {
            $filter[$no++] = " SUBSTR(B.SEGMENT5,1,4) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'output') {
            $filter[$no++] = " B.SEGMENT5 =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'jenbel') {
            $filter[$no++] = " SUBSTR(B.SEGMENT3,1,2) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'sdana') {
            $filter[$no++] = " SUBSTR(B.SEGMENT6,1,1) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'es1jenbel') {
            $filter[$no++] = " SUBSTR(B.SEGMENT4,1,5)||'-'||SUBSTR(B.SEGMENT3,1,2) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'es1sdana') {
            $filter[$no++] = " SUBSTR(B.SEGMENT4,1,5)||'-'||SUBSTR(B.SEGMENT6,1,1) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'satjenbel') {
            $filter[$no++] = " B.SEGMENT1||'-'||SUBSTR(B.SEGMENT3,1,2) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'satsdana') {
            $filter[$no++] = " B.SEGMENT1||'-'||SUBSTR(B.SEGMENT6,1,1) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'ba') {
            $filter[$no++] = "SUBSTR(B.SEGMENT4,1,3) =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        } elseif ($detil == 'akun') {
            $filter[$no++] = "segment3 =  '" . $code_id . "'";
            $this->view->kd_code_id = $code_id;
        }

        $this->view->data = $d_spm1->get_encumbrances_baes1($filter);
		$this->view->action = 'DetailEncumbrances_BAES1';
        $this->view->judul = urldecode($judul);
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/encumbrances');
    }

    public function DataRealisasiKegiatanBAES1() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $filter1 = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));


        if (isset($_POST['kegiatan'])) {

            if ($_POST['kegiatan'] != '') {
                $filter[$no++] = "KEGIATAN = '" . $_POST['kegiatan'] . "'";
                $this->view->kegiatan = $_POST['kegiatan'];
            }
        }

        if (isset($_POST['submit_file'])) {

            if (isset($_POST['kegiatan'])) {

                if ($_POST['kegiatan'] != '') {
                    $filter[$no++] = "KEGIATAN = '" . $_POST['kegiatan'] . "'";
                    $this->view->kegiatan = $_POST['kegiatan'];
                }
            }

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '" . $_POST['bln_akhir'] . "' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
                $this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        if (Session::get('role') == KL) {
            if (('' . Session::get('ta')) == date("Y")) {

                $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
                $filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_kegiatan_baes1_filter($filter);
            } else {

                $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
                $filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_kegiatan_baes1_filter_tl($filter);
            }
        }

        if (Session::get('role') == ES1) {
            if (('' . Session::get('ta')) == date("Y")) {

                $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
                $filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_kegiatan_baes1_filter($filter);
            } else {

                $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
                $filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
                $this->view->data = $d_spm1->get_realisasi_fa_kegiatan_baes1_filter_tl($filter);
            }
        }


        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        //$this->view->data = $d_spm1->get_realisasi_fa_kegiatan_baes1_filter($filter);
        $this->view->data1 = $d_spm1->get_nama_kegiatan_filter($filter1);
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKegiatanBAES1');
    }

    public function DataRealisasiSumberDanaBAES1() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
    

        if (isset($_POST['submit_file'])) {

           if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

       
		if (Session::get('role') == KANWIL) {
           
			if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "KANWIL = '" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter_tl($filter);
				}
        }
		
		if (Session::get('role') == KL) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == ES1) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == MENKEU) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter($filter);
				}
				else {
			  
					
					$this->view->data = $d_spm1->get_realisasi_fa_sumber_dana_baes1_filter_tl($filter);
				}
		}

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiSumberDanaBAES1');
    }

    public function DataRealisasiWilayahBAES1() {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        
       
        if (isset($_POST['submit_file'])) {

            if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        if (Session::get('role') == KANWIL) {
           
			if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "KANWIL = '" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter_tl($filter);
				}
        }
		
		if (Session::get('role') == KL) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == ES1) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == MENKEU) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter($filter);
				}
				else {
			  
					
					$this->view->data = $d_spm1->get_realisasi_fa_wilayah_baes1_filter_tl($filter);
				}
		}

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiLokasiBAES1');
    }

    public function DataRealisasiKabupatenBAES1($wilayah = null, $nmwilayah = null ,
	$bln_awal = null, $bln_akhir = null) {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if ($wilayah != '') {
            $filter[$no++] = "substr(a.lokasi,1,2) = '" . $wilayah . "'";
            $this->view->wilayah = $wilayah;
        }

        if ($nmwilayah != '') {

            $this->view->nmwilayah = urldecode($nmwilayah);
        }

        if ($bln_awal != '' and $bln_akhir != '') {

             
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $bln_awal . "' AND '". $bln_akhir ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $bln_awal;
				$this->view->bln_akhir = $bln_akhir;
            
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
		
        //$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter($filter);
        
		  if (Session::get('role') == KANWIL) {
           
			if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "KANWIL_DJPB = 'K" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "KANWIL = '" . Session::get('id_user') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter_tl($filter);
				}
        }
		
		if (Session::get('role') == KL) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == ES1) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter($filter);
				}
				else {
			  
					$filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$filter1[$no++] = "SUBSTR(A.PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter_tl($filter);
				}
		}
		
		if (Session::get('role') == MENKEU) {
				if ((''.Session::get('ta')) == date("Y")) {
			 
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter($filter);
				}
				else {
			  
					
					$this->view->data = $d_spm1->get_realisasi_fa_kabupaten_baes1_filter_tl($filter);
				}
		}
		
		$this->view->data1 = $d_spm1->get_wilayah($wilayah);
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKabupatenBAES1');
    }

    public function nmsatker() {
        $d_spm1 = new DataNamaSatker($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table4());

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        if (isset($_POST['submit_file'])) {

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->kdsatker = $_POST['kdsatker'];
            }
            if ($_POST['nmsatker'] != '') {
                $filter[$no++] = " UPPER(A.NMSATKER) LIKE UPPER('%" . $_POST['nmsatker'] . "%')";
                $this->view->d_nm_satker = $_POST['nmsatker'];
            }
            if ($_POST['eselon1'] != '') {
                $filter[$no++] = "B.BAES1 = '" . $_POST['eselon1'] . "'";
                $this->view->kdeselon1 = $_POST['eselon1'];
            }
            if ($_POST['revisi'] != '') {
                if ($_POST['revisi'] == '0') {
                    $filter[$no++] = "A.REV = 0";
                    $this->view->d_kd_revisi = $_POST['revisi'];
                } elseif ($_POST['revisi'] == '1') {
                    $filter[$no++] = "A.REV > 0";
                    $this->view->d_kd_revisi = $_POST['revisi'];
                }
            }
        }

        $this->view->data = $d_spm1->get_baes1_dipa_filter($filter);
        $this->view->data1 = $d_spm1->get_es1_dipa_filter();

        if (Session::get('role') == ES1) {
            $this->view->render('baes1/NamaSatkerDIPA1');
        }

        if (Session::get('role') == KL) {
            $this->view->render('baes1/NamaSatkerDIPA');
        }


        $d_log->tambah_log("Sukses");
        //var_dump($d_spm1->get_satker_filter($filter));
        //$this->view->render('kppn/NamaSatkerDIPA1');
    }

    public function ProsesRevisi($satker = NULL) {
        $d_spm1 = new proses_revisi($this->registry);
        $filter = array();
        $no = 0;

        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        if ($satker != '') {
            $filter[$no++] = " A.SATKER_CODE =  '" . $satker . "'";
            $this->view->satker_code = $satker;
        }
        if (isset($_POST['submit_file'])) {

            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "A.KPPN_CODE = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
            }
            /* else {
              $filter[$no++]="TS.KPPN = '".Session::get('id_user')."'";
              } */

            if ($_POST['satker'] != '') {
                $filter[$no++] = "A.SATKER_CODE = '" . $_POST['satker'] . "'";
                $this->view->d_kd_satker = $_POST['satker'];
            }
            if ($_POST['nmsatker'] != '') {
                $filter[$no++] = " UPPER(B.NMSATKER) LIKE UPPER('%" . $_POST['nmsatker'] . "%')";
                $this->view->d_nm_satker = $_POST['nmsatker'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_revisi_dipa($filter);

        $this->view->render('baes1/proses_revisi');
        $d_log->tambah_log("Sukses");
    }

    public function RekapSp2dBAES1() {
        $d_spm1 = new DataCheck($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (('' . Session::get('ta')) == date("Y")) {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2015'";
        } else {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2014'";
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        if (isset($_POST['submit_file'])) {


            if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
                $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }
        }

        //$this->view->data = $d_spm1->get_sp2d_rekap_filter ($filter);
        //var_dump($d_spm1->get_error_spm_filter ($filter));

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_sp2d_rekap_baes1_filter($filter);

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/RekapSP2D');
    }

    public function detailrekapsp2dBAES1($jenis_spm = null, $kppn = null, $tgl_awal = null, $tgl_akhir = null) {
        $d_spm1 = new DataCheck($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (('' . Session::get('ta')) == date("Y")) {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2015'";
        } else {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2014'";
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "SEGMENT1 IN (SELECT KDSATKER FROM T_SATKER WHERE BA = '" . Session::get('kd_baes1') . "')";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "SEGMENT1 IN (SELECT KDSATKER FROM T_SATKER WHERE BAES1 = '" . Session::get('kd_baes1') . "')";
        }

        if ($jenis_spm != '') {
            $filter[$no++] = " JENDOK =  '" . $jenis_spm . "'";
            $this->view->jendok1 = $jenis_spm;
        }

        if ($tgl_awal != '' AND $tgl_akhir != '') {

            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($tgl_awal)) . "' AND '" . date('Ymd', strtotime($tgl_akhir)) . "'";

            $this->view->d_tgl_awal = $tgl_awal;
            $this->view->d_tgl_akhir = $tgl_akhir;
        }

        $this->view->data = $d_spm1->get_sp2d_satker_filter($filter);

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/Rekap');
    }

    public function nmsatkerBAES1() {
        $d_spm1 = new DataNamaSatker($this->registry);

        $filter = array();
        $no = 0;

        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (('' . Session::get('ta')) == date("Y")) {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2015'";
        } else {
            $filter[$no++] = "TO_CHAR(CHECK_DATE,'YYYY') = '2014'";
        }


        if (isset($_POST['submit_file'])) {

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "SEGMENT1 = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kd_satker = $_POST['kdsatker'];
            }
            if ($_POST['nmsatker'] != '') {
                $filter[$no++] = " UPPER(NMSATKER) LIKE UPPER('%" . $_POST['nmsatker'] . "%')";
                $this->view->d_nm_satker = $_POST['nmsatker'];
            }
            if ($_POST['eselon1'] != '') {
                $filter[$no++] = "B.BAES1 = '" . $_POST['eselon1'] . "'";
                $this->view->eselon1 = $_POST['eselon1'];
            }
            if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {

                $filter[$no++] = "TO_CHAR(CREATION_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }
        }
        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table2());

        $this->view->data1 = $d_spm1->get_es1_dipa_filter();
        $this->view->data = $d_spm1->get_baes1_satker_filter($filter);

        $this->view->render('baes1/NamaSatker');
        $d_log->tambah_log("Sukses");
    }

    //author by jhon

    public function DataRealisasiOutputBA() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $d_spm2 = new DataRealisasi($this->registry);
            $this->view->data2 = $d_spm2->get_nama_BA('');
        }
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['KodeBA'] != '') {
                $filter[$no++] = "substr(program,1,3) = '" . $_POST['KodeBA'] . "'";
                $this->view->kdba = $_POST['KodeBA'];
            }
            if ($_POST['kode'] != '') {
                $filter[$no++] = "OUTPUT like '%" . $_POST['kode'] . "%'";
                $this->view->kdoutput = $_POST['kode'];
            }

            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(d.nmkegiatan) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmoutput = $_POST['nama'];
            }

            if (Session::get('role') == KL) {
                $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
            } elseif (Session::get('role') == ES1) {
                $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
            } elseif (Session::get('role') == SATKER) {
                $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
            } elseif (Session::get('role') == KANWIL) {
                $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
            }

            $this->view->data = $d_spm1->get_ba_output_filter($filter);
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Output';
        $this->view->judulkolom = 'Kode | Nama Kegiatan / Output';
        $this->view->action = 'DataRealisasiOutputBA';
        $this->view->kodes = 'Kode Output :';
        $this->view->detil = 'output :';
        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataFaBaPerEs1() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "substr(program,1,5) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }

            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(nmes1) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->data = $d_spm1->get_ba_per_es1_filter($filter);
        $this->view->judul = 'Laporan Pagu Dana Per Eselon 1';
        $this->view->judulkolom = 'Kode | Nama Eselon 1';
        $this->view->action = 'DataFaBaPerEs1';
        $this->view->kodes = 'Kode Eselon 1:';
        $this->view->detil = "eselon";
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKegiatan');
    }

    public function DataFaBaSatEs1() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        if (Session::get('role') == MENKEU || Session::get('role') == DJA) {
            $d_spm2 = new DataRealisasi($this->registry);
            $this->view->data2 = $d_spm2->get_nama_BA('');
        }
        $filter = array();
        $no = 0;
        $this->view->judul = 'Laporan Pagu Dana Per Satker';
        $this->view->judulkolom = 'Kode | Nama Eselon 1 / Satker';
        $this->view->action = 'DataFaBaSatEs1';
        $this->view->kodes = 'Kode Satker :';
        $this->view->detil = 'satker :';
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {
            if ($_POST['KodeBA'] != '') {
                $filter[$no++] = "substr(program,1,3) = '" . $_POST['KodeBA'] . "'";
                $this->view->kdba = $_POST['KodeBA'];
            }

            if ($_POST['kode'] != '') {
                $filter[$no++] = "satker like '%" . $_POST['kode'] . "%'";
                $this->view->kdoutput = $_POST['kode'];
            }

            /* if (isset($_POST['submit_file'])) {

              if ($_POST['nama'] != '') {
              $filter[$no++] = "nmsatker like '%" . $_POST['nama'] . "%'";
              $this->view->nmoutput = $_POST['nama'];
              }
              } */

            if (Session::get('role') == KL) {
                $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
            } elseif (Session::get('role') == ES1) {
                $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
            } elseif (Session::get('role') == KANWIL) {
                $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
            }

            $d_last_update = new DataLastUpdate($this->registry);
            $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
            $this->view->data = $d_spm1->get_ba_persates1_filter($filter);
        }
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataFaBaPerJenbel() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "substr(akun,1,2) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }

            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(nmakun) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->data = $d_spm1->get_ba_per_jenbel_filter($filter);
        $this->view->judul = 'Laporan Pagu Dana Per Jenis Belanja';
        $this->view->judulkolom = 'Kode | Nama Jenis Belanja';
        $this->view->action = 'DataFaBaPerJenbel';
        $this->view->kodes = 'Kode Jenis Belanja:';
        $this->view->detil = "jenbel";
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKegiatan');
    }

    public function DataFaBaPerSdana() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "substr(dana,1,1) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }

            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(deskripsi) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->data = $d_spm1->get_ba_per_sdana_filter($filter);
        $this->view->judul = 'Laporan Pagu Dana Per Sumber Dana';
        $this->view->judulkolom = 'Kode | Nama Sumber Dana';
        $this->view->action = 'DataFaBaPerSdana';
        $this->view->kodes = 'Kode Sumber Dana:';
        $this->view->detil = "sdana";
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKegiatan');
    }

    public function DataFaBaEs1Jenbel() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "SUBSTR(program,1,5) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }
        }
        /* if (isset($_POST['submit_file'])) {

          if ($_POST['nama'] != '') {
          $filter[$no++] = "nmsatker like '%" . $_POST['nama'] . "%'";
          $this->view->nmkegiatan = $_POST['nama'];
          }
          } */
        $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_ba_peres1jenbel_filter($filter);
        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Eselon 1 - Jenis Belanja';
        $this->view->judulkolom = 'Kode | Nama Eselon 1 / Jenis Belanja';
        $this->view->action = 'DataFaBaEs1Jenbel';
        $this->view->kodes = 'Kode Eselon 1 :';
        $this->view->detil = 'es1jenbel :';
        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataFaBaEs1Sdana() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "SUBSTR(program,1,5) like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }
        }
        /* if (isset($_POST['submit_file'])) {

          if ($_POST['nama'] != '') {
          $filter[$no++] = "nmsatker like '%" . $_POST['nama'] . "%'";
          $this->view->nmkegiatan = $_POST['nama'];
          }
          } */
        $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_ba_peres1sdana_filter($filter);
        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Eselon 1 - Sumber Dana';
        $this->view->judulkolom = 'Kode | Nama Eselon 1 / Sumber Dana';
        $this->view->action = 'DataFaBaEs1Sdana';
        $this->view->kodes = 'Kode Eselon 1 :';
        $this->view->detil = 'es1sdana :';
        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataFaEs1PerSat() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "satker like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }

            if ($_POST['nama'] != '') {
                $filter[$no++] = " nmsatker like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        $this->view->data = $d_spm1->get_es1_persat_filter($filter);
        $this->view->judul = 'Laporan Pagu Dana Per Satker';
        $this->view->judulkolom = 'Kode | Nama Satker';
        $this->view->action = 'DataFaEs1PerSat';
        $this->view->kodes = 'Kode Satker:';
        $this->view->detil = "satker";
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/DataRealisasiKegiatan');
    }

    public function DataFaEs1SatJenbel() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "satker like '%" . $_POST['kode'] . "%'";
                $this->view->kdoutput = $_POST['kode'];
            }
        }
        /* if (isset($_POST['submit_file'])) {

          if ($_POST['nama'] != '') {
          $filter[$no++] = "nmsatker like '%" . $_POST['nama'] . "%'";
          $this->view->nmkegiatan = $_POST['nama'];
          }
          } */
        if (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_fa_es1_persatjenbel_filter($filter);
        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Satker - Jenis Belanja';
        $this->view->judulkolom = 'Kode | Nama Satker / Jenis Belanja';
        $this->view->action = 'DataFaEs1SatJenbel';
        $this->view->kodes = 'Kode Satker :';
        $this->view->detil = 'satjenbel :';
        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataFaEs1SatSdana() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "satker like '%" . $_POST['kode'] . "%'";
                $this->view->kdoutput = $_POST['kode'];
            }
        }
        /* if (isset($_POST['submit_file'])) {

          if ($_POST['nama'] != '') {
          $filter[$no++] = "nmsatker like '%" . $_POST['nama'] . "%'";
          $this->view->nmoutput = $_POST['nama'];
          }
          } */
        if (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_fa_es1_persatsdana_filter($filter);
        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Satker - Sumber Dana';
        $this->view->judulkolom = 'Kode | Nama Satker / Sumber Dana';
        $this->view->action = 'DataFaEs1SatSdana';
        $this->view->kodes = 'Kode Satker :';
        $this->view->detil = 'satsdana :';
        $this->view->render('baes1/DataRealisasiOutput');
    }

    public function DataUPBAES1() {
        $d_spm1 = new DataKarwasUP($this->registry);
        $filter = array();
        //$filter2 = array();
        $no = 0;

        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        if (isset($_POST['submit_file'])) {




            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.SATKER_CODE = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kd_satker = $_POST['kdsatker'];
            }
            if ($_POST['SUMBERDANA'] != '') {
                $filter[$no++] = "SUMBER_DANA = '" . $_POST['SUMBERDANA'] . "'";
                $this->view->d_sumber_dana = $_POST['SUMBERDANA'];
            }
        }

        $this->view->data1 = $d_spm1->get_karwas_up_baes1($filter);
        $this->view->data2 = $d_spm1->get_total_sisa_up_baes1($filter);

        $d_log->tambah_log("Sukses");
        $this->view->render('baes1/KarwasUPBAES1');
    }

    public function KarwasTUPBaes1() {
        $d_spm1 = new DataKarwasUP($this->registry);
        $filter = array();
        //$filter2 = array();
        $no = 0;

        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "B.BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "B.BAES1 = '" . Session::get('kd_baes1') . "'";
        }

        if (isset($_POST['submit_file'])) {


            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "SATKER_CODE = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kd_satker = $_POST['kdsatker'];
            }
            if ($_POST['SUMBERDANA'] != '') {
                $filter[$no++] = "SUMBER_DANA = '" . $_POST['SUMBERDANA'] . "'";
                $this->view->d_sumber_dana = $_POST['SUMBERDANA'];
            }
        }

        $this->view->data1 = $d_spm1->get_karwas_tup_baes1($filter);
        $this->view->data2 = $d_spm1->get_total_sisa_tup_baes1($filter);

        $d_log->tambah_log("Sukses");
        $this->view->render('baes1/KarwasTUPBAES1');
    }

    public function DataFaPerBA() {
        $d_spm1 = new DataRealisasiES1($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kode'] != '') {
                $filter[$no++] = "kode_kegiatan like '%" . $_POST['kode'] . "%'";
                $this->view->kdkegiatan = $_POST['kode'];
            }
            if ($_POST['nama'] != '') {
                $filter[$no++] = " upper(nmba) like upper('%" . $_POST['nama'] . "%')";
                $this->view->nmkegiatan = $_POST['nama'];
            }
        }

        if (Session::get('role') == KANWIL) {
            $filter2[$no++] = " KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_fa_perba_filter($filter,$filter2);

        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Per Bagian Anggaran';
        $this->view->judulkolom = 'Kode | Nama Bagian Anggaran';
        $this->view->action = 'DataFaPerBA';
        $this->view->kodes = 'Kode BA :';
        $this->view->detil = "ba";
        $this->view->render('baes1/DataRealisasiKegiatan');
    }
	
	public function PaguMinusBAES1($akun) {
        $d_spm1 = new DataFA($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
			 $this->view->ba = Session::get('kd_baes1');
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        }
		
		if ($akun == '50') {
			 $filter[$no++] = "SUBSTR(A.AKUN,1,2) <> 'B1'";
			 $this->view->judul = "Non Belanja Pegawai";
			 $this->view->account_code1 = $akun;
		}
		
		if ($akun == '51') {
			 $filter[$no++] = "SUBSTR(A.AKUN,1,2) = 'B1'";
			 $this->view->judul = "Belanja Pegawai";
			 $this->view->account_code1 = $akun;
		}
		
        if (isset($_POST['submit_file'])) {


            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "A.KPPN = '" . $_POST['kdkppn'] . "'";
                $this->view->kppn_code = $_POST['kdkppn'];
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
            }

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.SATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->satker_code = $_POST['kdsatker'];
            }
            if ($_POST['akun'] != '') {
                $filter[$no++] = "A.AKUN = '" . $_POST['akun'] . "'";
                $this->view->account_code = $_POST['akun'];
            }
            if ($_POST['output'] != '') {
                $filter[$no++] = "A.OUTPUT = '" . $_POST['output'] . "'";
                $this->view->output_code = $_POST['output'];
            }
            if ($_POST['program'] != '') {
                $filter[$no++] = "A.PROGRAM = '" . $_POST['program'] . "'";
                $this->view->program_code = $_POST['program'];
            }
            if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
                $filter[$no++] = "A.TANGGAL_POSTING_REVISI BETWEEN '" . $_POST['tgl_awal'] . "' AND '" . $_POST['tgl_akhir'] . "'";
                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }
        }
       
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_fa_summary_minus_filter($filter);
        //var_dump($d_spm->get_hist_spm_filter());
		$this->view->action ='PaguMinusBAES1';
        $d_log->tambah_log("Sukses");

        $this->view->render('baes1/pagu_minus');
    }


    public function DataPembiayaan() {
        $d_spm1 = new DataRealisasiES1($this->registry);

        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }

        $this->view->data = $d_spm1->get_fa_pembiayaan($filter);

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");
        $this->view->judul = 'Laporan Pagu Dana Pembiayaan';
        $this->view->judulkolom = 'Kode | Uraian';
        $this->view->action = 'DataPembiayaan';
        $this->view->kodes = 'Kode Akun :';
        $this->view->detil = 'akun :';
        $this->view->render('baes1/DataPembiayaan');
    }
    
        public function DetailAkunPembiayaan($code=null,$judul=null) {
        $d_spm1 = new DataRealisasiES1($this->registry);

        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if ($code!=null) {
            $filter[$no++] = "akun = '" . $code. "'";
			$this->view->code = $code;
        }
        if (Session::get('role') == KL) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,3) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == ES1) {
            $filter[$no++] = "SUBSTR(PROGRAM,1,5) = '" . Session::get('kd_baes1') . "'";
        } elseif (Session::get('role') == SATKER) {
            $filter[$no++] = "SATKER = '" . Session::get('kd_satker') . "'";
        } elseif (Session::get('role') == KANWIL) {
            $filter[$no++] = "KPPN IN (SELECT KDKPPN FROM T_KPPN WHERE KDKANWIL= '" . Session::get('id_user') . "')";
        }

        $this->view->data = $d_spm1->get_detail_akun_pembiayaan($filter);

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");
        if ($judul!=null){
        $this->view->judul = "Detail Pembiayaan: ". ($judul)." (".$code.")";
        }
    //    $this->view->judulkolom = 'Kode | Uraian';
        $this->view->action = 'DetailAkunPembiayaan';
    //    $this->view->kodes = 'Kode Akun :';
        $this->view->render('baes1/DetailAkunPembiayaan');
    }
	
	 public function DataDetailSuspendBelanja($kode=null, $bln_awal = null, $bln_akhir = null) {
        $d_spm1 = new DataRealisasi($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == KL) {
            $filter[$no++] = "BA = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == ES1) {
            $filter[$no++] = "BAES1 = '" . Session::get('kd_baes1') . "'";
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " KDSATKER =  '" . Session::get('kd_satker') . "'";
        }

        if (Session::get('role') == KANWIL) {
            $filter[$no++] = " KANWIL_DJPB =  '" . Session::get('id_user') . "'";
        }

        if ($kode != '') {
		
			if ($kode == 'DANA'){
				$filter[$no++] = "SUBSTR(DANA,1,1) = 'Z'";			
			}
			elseif ($kode == 'KEGIATAN'){
				$filter[$no++] = "SUBSTR(OUTPUT,1,4)= 'ZZZZ'";			
			}
			elseif ($kode == 'KEWENANGAN'){
				$filter[$no++] = "KEWENANGAN= 'Z'";			
			}
			else {
				$filter[$no++] = $kode . " LIKE  '%Z%'";
            }
			$this->view->kode = "JENIS ".$kode;
			$this->view->kdkode =$kode;
        }
		
		if ($bln_awal != 0 AND $bln_akhir != 0) {

          $filter[$no++] = "TO_CHAR(TGLPOST,'MM') BETWEEN '" . $bln_awal . "' AND '" . $bln_akhir . "'";
		  $this->view->bln_awal = $bln_awal;
		  $this->view->bln_akhir = $bln_akhir;
		}      

        
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        
        $this->view->data = $d_spm1->get_detail_suspend_belanja($filter);
        
        $d_log->tambah_log("Sukses");
		$this->view->action='DataDetailSuspendBelanja';

        $this->view->render('baes1/SuspendBelanja');
    }

    public function __destruct() {
        
    }

}
